//引入axios实例
import {request,requestMock} from "@/utils/Http"

//请求mock中的banner数据
export const requestBannerList = () => {
    return requestMock.get("/banner")
}

//请求mock中的floor数据
export const requestFloorList = () => {
    return requestMock.get("/floor")
}




//1.三级列表请求
export const requestCateGoryList = () => {
    return request.get("/api/product/getBaseCategoryList")
}

//2.商品详情请求
export const requestSearchList = (searchParams) => {
    return request.post("/api/list" , searchParams)
}

//3.请求单个商品详情
export const requestDetailList = (skuId) => {
    return request.get(`/api/item/${skuId}`)
}

//4.添加到购物车(或者对已有物品进行数量改动)的请求
export const requestAddOrUpdateCartList = ({skuId , skuNum}) => {
    return request.post(`/api/cart/addToCart/${ skuId }/${ skuNum }`)
}

//5.获取购物车列表
export const requestGetShopCartList = () => {
    return request.get("/api/cart/cartList")
}

//6.删除单个商品
export const requestDeleteSingle = (skuId) => {
    return request.delete(`/api/cart/deleteCart/${skuId}`)
}

//7.切换单个商品状态
export const requestSingleChecked = ({skuId , isChecked}) => {
    return request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
}

//8.切换已选中的商品的状态
export const requestAllChecked = (isChecked , skuIdList) => {
    return request.post(`/api/cart/batchCheckCart/${isChecked}` , skuIdList)
}

//9.删除已选中的商品的请求
export const requestDeleteChecked = (skuIdList) => {
    return request.delete(`/api/cart/batchDeleteCart` , {
        data: skuIdList  
    })
}





//10.获取验证码请求
export const requestGetCode = (phone) => {
    return request.get(`/api/user/passport/sendCode/${phone}`)
}

//11.注册用户请求
export const requestRegisterUser = ({phone , password , code}) => {
    return request.post(`/api/user/passport/register` , {
        phone,
        password,
        code,
    })
}

//12.登录请求
export const requestGotoLogin = (userInfo) => {
    return request.post(`/api/user/passport/login` , userInfo)
}

//13.获取用户名请求
export const requestGetUserName = () => {
    return request.get(`/api/user/passport/auth/getUserInfo`)
}

//14.退出登录请求
export const requestGetLogOut = () => {
    return request.get(`/api/user/passport/logout`)
}

//15.请求交易页数据
export const requestTardeInfo = () => {
    return request.get("/api/order/auth/trade")
}

//16.请求交易页地址请求请求
export const requestTardeAddress = () => {
    return requestMock.get("/address")
}

//17.提交请求的请求
export const requestSubmitOrder = (tradeNo , tardeInfo) => {
    return request.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}` , tardeInfo)
}


